package com.angus.common.core.validator;

import com.angus.common.core.annotation.Mobile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author liyanan
 * @date 2024/09/26 2:45 PM
 * @description
 */
public class MobileValidator implements ConstraintValidator<Mobile, String> {

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null) {
        return true;
        }
        // 使用正则表达式进行手机号码验证
        return value.matches("^1[3-9]\\d{9}$");
        }
}
